﻿using ZYCommon;
using System;
using System.Xml;

namespace TextEditor
{
  

    public class UnderWriteMark : IXMLSerializable
    {
        public DateTime MarkTime;
        public int SaveLogIndex;
        public string Senior;
        public string UserName;

        public string DisplayText()
        {
            return (this.UserName + " 签名于" + this.MarkTime.ToString("yyyy年MM月dd日 HH:mm"));
        }

        public bool FromXML(XmlElement RootElement)
        {
            if (RootElement != null)
            {
                this.UserName = RootElement.GetAttribute("username");
                this.MarkTime = StringCommon.ConvertToDateTime(RootElement.GetAttribute("marktime"), null, DateTime.Now);
                this.Senior = RootElement.GetAttribute("senior");
                this.SaveLogIndex = StringCommon.ToInt32Value(RootElement.GetAttribute("savelog"), 0);
                return true;
            }
            return false;
        }

        public string GetXMLName()
        {
            return "underwritemark";
        }

        public bool ToXML(XmlElement RootElement)
        {
            if (RootElement != null)
            {
                RootElement.SetAttribute("username", this.UserName);
                RootElement.SetAttribute("marktime", this.MarkTime.ToString("yyyy-MM-dd HH:mm:ss"));
                RootElement.SetAttribute("senior", this.Senior);
                RootElement.SetAttribute("savelog", this.SaveLogIndex.ToString());
                return true;
            }
            return false;
        }
    }
}

